import Vue from 'vue'
import VueI18n from 'vue-i18n'

import ElementLocale from 'element-ui/lib/locale'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import enLocale from 'element-ui/lib/locale/lang/en'

import langZh from "./languages/zh.js"
import langEN from "./languages/en.js"

Vue.use(VueI18n)

// console.log(navigator.language);
let lang = navigator.language
if (lang.indexOf('zh') == 0) {
	lang = 'zh'
} else {
	lang = 'en'
}

const i18n = new VueI18n({
	locale: lang,
	messages: {
		'zh': {
			...langZh,
			...zhLocale
		},
		'en': {
			...langEN,
			...enLocale
		}
	}
})
ElementLocale.i18n((key, value) => i18n.t(key, value))

export default i18n
